package com.example.testing.ipcdemo;

import android.os.RemoteException;

import java.util.List;

/**
 * Created by tangjiangxu on 9/4/17.
 */

public class BinderService {
    private List<Book> mBookList;
    private final IBookManager.Stub mBinder = new IBookManager.Stub() {

        @Override
        public List<Book> getBookList() throws RemoteException {
            synchronized (mBookList) {
                return mBookList;
            }
        }

        @Override
        public void addBook(Book book) throws RemoteException {
            synchronized (mBookList) {
                if (!mBookList.contains(book)) {
                    mBookList.add(book);
                }
            }
        }

        @Override
        public void registerLisenter(IOnNewBookArrivedListener listener) throws RemoteException {

        }

        @Override
        public void unRegisterLisenter(IOnNewBookArrivedListener listener) throws RemoteException {

        }
    };
}
